import React from 'react';
import { Card } from 'antd';
import { TableContainer, PageTable, SearchBar } from 'components'

export default class extends React.Component {
	columns = [
		{
			title: '排序',
			dataIndex: 'key',
			align: "center",
		},
		{
			title: '角色名',
			dataIndex: 'role',
		},
		{
			title: '备注',
			dataIndex: 'description',
		},
		{
			title: 'ID',
			dataIndex: 'id',
		},
		{
			title: 'kid',
			dataIndex: 'kid',
		},
		{
			title: '操作',
			dataIndex: 'operation',
			render: (text: string, record: any, index: number) => this.renderTableButton(text, record, index)
		}
	]
	state = {
		request: {
			url: '/gateway/PLATFORM-SUPPORT/v1/pv/roles/action/search',
			params: {
				offset: 0,
				limit: 30,
			}
		},
		model: {}
	}
	searchBarConfig = [
		[
			{
				label: '邮箱',
				field: 'email',
				renderType: 'input',
				placeholder: '请输入邮箱',
				// decoratorOptions: {
				// 	initialValue: '23371891@qq.com',
				// 	rules: [{
				// 		type: 'email', message: '邮箱格式不正确',
				// 	}, {
				// 		required: true, message: '请输入邮箱',
				// 	}]
				// },
			},
			{
				label: '类型',
				field: 'moduleCode',
				renderType: 'select',
				options: [{
					value: "1001",
					name: "应用"
				},
				{
					value: "1002",
					name: "文章"
				}],
				placeholder: '请选择类型',
				style: { width: '150px' },
				decoratorOptions: {
					initialValue: '应用'
				},
			}
		],
		[
			{
				label: '报名日期',
				width: 16,  // 宽度
				field: 'singupDate',
				// field: ['startSingupTime', 'endSingupTime'],
				renderType: 'rangePicker',
				format: "YYYY/MM/DD",
				placeholder: ['开始日期', '结束日期'],
			}
		]
	]
	private renderTableButton = (text: string, record: any, index: number) => {
		const actionCode = record.isRecommend ? '200421' : '200406'
		return (
			<div>
				<div>
					<a href="/">编辑</a>
					<a href="/">删除</a>
				</div>
			</div >
		);
	}

	render() {
		const columns = this.columns;
		const searchBarConfig = this.searchBarConfig;
		const { request, model } = this.state;
		const { offset, limit } = request.params;
		const pagination = { offset, limit };
		return (
			<div>
				<TableContainer>
					<SearchBar
						searchBarConfig={searchBarConfig}
					/>
					<PageTable
						bordered={true}
						size="middle"
						actionCode="02010100"
						// request={request}
						columns={columns}
						// pagination={pagination}
						style={{ marginTop: '10px' }}
					/>
				</TableContainer>
			</div>
		)
	}
}